<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改景区信息')" />
    <th:block th:include="include :: summernote-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-spot-edit" th:object="${scenicSpot}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">景区名称：</label>
                <div class="col-sm-8">
                    <input name="name" th:field="*{name}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">景区坐标点：</label>
                <div class="col-sm-8">
                    <div class="input-group">
                        <input class="form-control" type="text" onclick="selectCoordinate()"  name="coordinate" id="coordinate" th:field="*{coordinate}" readonly="true" >
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">景区级别：</label>
                <div class="col-sm-8">
                    <select class="form-control" th:with="type=${@dict.getType('sys_spot_type')}" name="level">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{level}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">景区类别：</label>
                <div class="col-sm-8">
                    <select class="form-control" th:with="type=${@dict.getType('sys_travel_preferences')}" name="category">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{category}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">景区地址：</label>
                <div class="col-sm-8">
                    <input name="address" th:field="*{address}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">门票数量：</label>
                <div class="col-sm-8">
                    <input name="ticketNum" th:field="*{ticketNum}" class="form-control" type="number">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">门票价格：</label>
                <div class="col-sm-8">
                    <input name="ticketPrice" th:field="*{ticketPrice}" class="form-control" type="number">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">景区详细介绍：</label>
                <div class="col-sm-8">
                    <input name="introduction" th:field="*{introduction}" class="form-control" type="text">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">景区攻略：</label>
                <div class="col-sm-8">
                    <input id="guide" name="guide" th:field="*{guide}" type="hidden">
                    <div id="editor" class="summernote"></div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">景区图片：</label>
                <div class="col-sm-8">
                    <input id="spotPic" name="spotPic"  onclick="uploadTupian()" th:field="*{spotPic}" type="text"  readonly="true"  >
                </div>
            </div>

        </form>
    </div>
    <div class="row">
        <div class="col-sm-offset-5 col-sm-10">
            <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
            <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: summernote-js" />
    <script type="text/javascript">
        var prefix = ctx + "lvyou/spot";
        $("#form-spot-edit").validate({
            focusCleanup: true
        });

        $(document).ready(function () {
            $('.summernote').summernote({
                lang: 'zh-CN'
            });
            var content = $("#guide").val();
            $('#editor').summernote('code', content);
        });

        function submitHandler() {
            if ($.validate.form()) {
                var html=$('#editor').summernote('code');
                $("#guide").val(html);
                $.operate.save(prefix + "/edit", $('#form-spot-edit').serialize());
            }
        }
        function selectCoordinate() {
            var options = {
                title: '景区坐标选择',
                width: "800",
                height:$(window).height() - 50,
                url: prefix + "/selectCoordinate?coordinate=" + $("#coordinate").val(),
                callBack: doSubmit
            };
            $.modal.openOptionsFull(options);
        }

        function doSubmit(index, layero){
            var body = layer.getChildFrame('body', index);
            //$("#name").val(body.find('#tipinput').val());  //搜索名称
            $("#coordinate").val(body.find('#coordinate').val());  //景区坐标
            layer.close(index);
        }

        function uploadTupian() {
            var options = {
                title: '景区坐标选择',
                width: "800",
                height:$(window).height() - 50,
                url: prefix + "/uploadTupian",
                callBack: doSubmit2
            };
            $.modal.openOptionsFull(options);
        }

        function doSubmit2(index, layero){
            var body = layer.getChildFrame('body', index);
            $("#spotPic").val(body.find('#spotPic').val());  //搜索名称
            layer.close(index);
        }
    </script>
</body>
</html>